<?php
/**
* Utilidad de graficos lineales usando jpgraph
* @file linegraph.php
* @author DYR Technologies
* @version V 1.0
* @date Wed Oct 03 2007
 *
 *  Part of the CEFIRO dynamic web framework project
 *
 *  Copyright (C) 2007  Dyr technologies http://dyrtech.com.ve
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
*
*/
include "basicgraph.php";
include "jpgraph_line.php";
include "jpgraph_date.php";

define('MARK_W',1);
define('MARK_C','black');
define('LINE_C','blue');


class lineGraph extends basicGraph {
  private $plot;

  public function lineGraph($nombre = null,
      $ancho = ANCHOXDEF, $alto = ALTOXDEF ){
    return parent::basicGraph($nombre,$ancho,$alto);
  }

  public function addPlot($datay, $datax = null, $offy = null, $offx = null,
      $legend = null, $markColor = MARK_C, $lineColor = LINE_C,
      $scale = 'texlin', $bMinMax = false){

    $this->graph->SetScale($scale);
    $this->plot = new LinePlot($datay);
    if(isset($legend)){
      $this->graph->img->SetMargin(50,150,60,60);
      $this->plot->SetLegend($legend);
    }else{
      $this->graph->img->SetMargin(50,50,60,50);
    }
    if (isset($datax)){
      if ($bMinMax)//{
        $this->graph->xaxis->SetLabelAngle(45);
//        $tickPositions = array(0,@count($datax)-1);
//        $tickLabels = array($datax[0],$datax[@count($datax)-1]);
//        $this->graph->xaxis->SetMajTickPositions($tickPositions,$tickLabels);
//      } else
        $this->graph->xaxis->SetTickLabels($datax);
      $this->graph->xaxis->SetFont(TIPO_FUENTE, TIPO_LETRA, 7);
    }
    if (isset($offx))
      $this->graph->yaxis->SetPos($offx);
    if (isset($offy))
      $this->graph->xaxis->SetPos($offy);
    $this->plot->mark->SetType(MARK_FILLEDCIRCLE);
    $this->plot->mark->SetFillColor($markColor);
    $this->plot->mark->SetWidth(MARK_W);
    $this->plot->SetColor($lineColor);
    $this->plot->SetCenter();
    $this->graph->Add($this->plot);
  }

}
?>